#pragma once

#include "Types.h"
#include "DLL.h"
#include <list>

namespace My {

enum Language {
	LANG_NONE,
	LANG_ENU,
	LANG_RUS,
	LANG_MAX
};

class DLLLanguage;
class AppLanguage;

String DLL_API GetLanguageSuffix(Language);
String DLL_API GetLanguageName(Language);

/**
 * Base class for language modules
 */
class DLL_API BasicLanguage {
public:
	BasicLanguage();
	~BasicLanguage();
public:
	void Init(HINSTANCE);
	void LoadModule(Language);
	void UnloadModule();
	HMODULE GetModule() const
		{ return m_hModule; }
	Language GetLanguage() const
		{ return m_Language; }
protected:
	static std::list<DLLLanguage *>		m_DLLs;
	static AppLanguage *				m_pApp;
private:
	HINSTANCE	m_hInstance;
	HMODULE		m_hModule;
	Language	m_Language;
};


/**
 * Keep a single global instance of this class
 * for each dll.
 */
class DLL_API DLLLanguage : public BasicLanguage {
public:
	/// Call this from DLL, when the language is not yet known
	void Init(HINSTANCE);
};

class DLL_API AppLanguage : public BasicLanguage {
public:
/// Call this from the main app
	void Init(const char * szSection, const char * szEntry);
public:
	/// Returns the language for the next startup
	Language GetStartupLanguage();
	/// Sets the language for the next startup
	void SetStartupLanguage(Language);
private:
	String		m_Section;
	String		m_Entry;
};

} // My
